import request from '@/config/axios'

// 渠道合作协议 VO
export interface TradeChannelAgreementVO {
  id: number // 主键ID
  companyId: number // 渠道ID
  agreementName: string // 协议名称
  agreementCode: string // 协议编码
  commissionMode: number // 佣金模式
  startTime: Date // 生效时间
  endTime: Date // 失效时间
  status: number // 状态(0=启用,1=禁用)
  remark: string // 备注
}

// 渠道合作协议 API
export const TradeChannelAgreementApi = {
  // 查询渠道合作协议分页
  getTradeChannelAgreementPage: async (params: any) => {
    return await request.get({ url: `/member/trade-channel-agreement/page`, params })
  },

  // 查询渠道合作协议详情
  getTradeChannelAgreementById: async (id: number) => {
    return await request.get({ url: `/member/trade-channel-agreement/getById?id=` + id })
  },

  // 新增渠道合作协议
  createTradeChannelAgreement: async (data: TradeChannelAgreementVO) => {
    return await request.post({ url: `/member/trade-channel-agreement/create`, data })
  },

  // 修改渠道合作协议
  updateTradeChannelAgreement: async (data: TradeChannelAgreementVO) => {
    return await request.post({ url: `/member/trade-channel-agreement/update`, data })
  },

  // 修改渠道合作协议状态
  updateTradeChannelAgreementStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/member/trade-channel-agreement/updateStatus`, data: data })
  },

  // 删除渠道合作协议
  deleteTradeChannelAgreementById: async (id: number) => {
    return await request.get({ url: `/member/trade-channel-agreement/delete?id=` + id })
  },

  // 导出渠道合作协议 Excel
  exportTradeChannelAgreement: async (params) => {
    return await request.download({ url: `/member/trade-channel-agreement/export-excel`, params })
  },
}
